import java.util.Stack;

public class LeetO06 {
    public int[] reversePrint(ListNode head) {
        Stack<Integer> stack = new Stack<>();
        while (head!=null){
            stack.push(head.val);
            head = head.next;
        }
        int[] re = new int[stack.size()];
        for (int i = 0; i < re.length; i++) {
            re[i] = stack.pop();
        }
        return re;
    }
}
